﻿using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Iesi.Collections.Generic;

namespace Apodidae.Domain.Entity
{
    public class ClassInfo : BaseObject<Int32>
    {
        public ClassInfo()
        {
            Students = new HashedSet<UserInfo>();
            Groups = new HashedSet<GroupInfo>();
        }
        /// <summary>
        /// 教师
        /// </summary>
        public virtual UserInfo Teacher { get; set; }

        /// <summary>
        /// 一对多：一个班级有多个学生
        /// </summary>
        public virtual ISet<UserInfo> Students { get; set; }
        public void AddStudents(UserInfo student)
        {
            student.ClassInfo = this;
            this.Students.Add(student);
        }
        public void RemoveStudents(UserInfo student)
        {
            this.Students.Remove(student);
        }

        /// <summary>
        /// 一对多：一个班级有多个小组
        /// </summary>
        public virtual ISet<GroupInfo> Groups { get; set; }
        public void AddGroups(GroupInfo groupInfo)
        {
            groupInfo.ClassInfo = this;
            this.Groups.Add(groupInfo);
        }
        public void RemoveGroups(GroupInfo groupInfo)
        {
            this.Groups.Remove(groupInfo);
        }
    }
}
